package com.wx.nchu_mall.web;

import com.wx.nchu_mall.model.Shopping;
import com.wx.nchu_mall.service.ShoppingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ShoppingController {
    @Autowired
    protected ShoppingService shoppingService;

    @PostMapping("/api/shopping/update")
    public String update(@RequestBody Shopping shopping){
        shoppingService.update(shopping);
        return "success";
    }
    @PostMapping("/api/shopping/findList")
    public List<Shopping> findList(@RequestBody Shopping shopping){
        return shoppingService.findList(shopping);
    }

    @PostMapping("/api/shopping/delete")
    public String delete(@RequestBody Shopping shopping){
        shoppingService.deleteById(shopping);
        return "success";
    }
    @PostMapping("/api/shopping/add")
    public String insert(@RequestBody Shopping shopping){
        shoppingService.insert(shopping);
        return "success";
    }
}
